#include <linux/init.h>
#include <linux/module.h>
#include <linux/radix-tree.h>

MODULE_LICENSE("Dual BSD/GPL");

#define NUM 5

void test_radix_tree(void)
{
	struct radix_tree_root root[1];
	__u64 data[NUM] = {10000, 20000, 10, 400, 3000}, *nodes[NUM];
	int i, cnt;
	
	INIT_RADIX_TREE(root, GFP_KERNEL);
	for (i = 0; i <  NUM; i++)
		radix_tree_insert(root, data[i], data + i);
	
	cnt = radix_tree_gang_lookup(root, (void **)nodes, 0, NUM);
	for (i = 0; i < cnt; i++) {
		radix_tree_delete(root, *(nodes[i]));
		printk(KERN_ERR "node %i is %llu\n", i, *(nodes[i]));
	}
	printk(KERN_ERR "NUM:%d:cnt:%d\n", NUM, cnt);
}

static __init int test_init(void)
{
	printk(KERN_ERR "test init \n");
	test_radix_tree();
	return 0;
}

static __exit void test_exit(void)
{
	printk(KERN_ERR "test exit \n");
}

module_init(test_init);
module_exit(test_exit);

